package com.budwk.app.sqfw.controllers.admin.communityservice;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.budwk.app.sqfw.services.communityservice.SqfwNoticeForAdminService;
import com.budwk.app.sqfw.vo.SqfwNoticeForAdminVO;
import com.budwk.app.sqfwDoc.bo.ExcelCreateConfig;
import com.budwk.starter.common.openapi.annotation.*;
import com.budwk.starter.common.page.Pagination;
import com.budwk.starter.common.result.Result;
import com.budwk.starter.log.annotation.SLog;
import lombok.extern.slf4j.Slf4j;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.*;

import java.util.List;

/**
 * @program: dfxy-community
 * @description: 社区公告（后台管理系统）
 * @author: LJT
 * @create: 2024-01-26 17:29
 **/
@IocBean
@At("/platform/sqfw/noticeForAdmin")
@ApiDefinition(tag = "社区公告（后台管理系统）")
@Slf4j
public class SqfwNoticeForAdminController {

    @Inject
    SqfwNoticeForAdminService sqfwNoticeForAdminService;

    /**
     * 列表查询
     */
    @At
    @Ok("json")
    @POST
    @ApiOperation(name = "列表查询")
    @ApiFormParams(
            value = {
                    @ApiFormParam(name = "pageNo", example = "1", description = "页码", type = "integer"),
                    @ApiFormParam(name = "pageSize", example = "10", description = "页大小", type = "integer"),
                    @ApiFormParam(name = "pageOrderName", example = "create_date", description = "排序字段"),
                    @ApiFormParam(name = "pageOrderBy", example = "descending", description = "排序方式")
            },
            implementation = SqfwNoticeForAdminVO.class
    )
    @ApiResponses(
            implementation = SqfwNoticeForAdminVO.class
    )
    @SLog(tag = "公共列表查询（后台管理系统）", value = "${args[0]}}")
    @SaCheckLogin
    public Result<?> list(@Param("..") SqfwNoticeForAdminVO bean,
                          @Param("pageNo") int pageNo,
                          @Param("pageSize") int pageSize,
                          @Param("pageOrderName") String pageOrderName,
                          @Param("pageOrderBy") String pageOrderBy) {
        Pagination pagination = sqfwNoticeForAdminService.list(bean, pageNo, pageSize, pageOrderName, pageOrderBy);
        return Result.data(pagination);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @At
    @Ok("json")
    @DELETE
    @ApiOperation(name = "删除列表信息")
    @ApiFormParams(
            {
                    @ApiFormParam(name = "id", description = "唯一标识", required = true, check = true)
            }
    )
    @SLog(tag = "删除消防信息", value = "${args[0]}")
    @SaCheckLogin
    public Result<?> delete(@Param("id") String id) {
        sqfwNoticeForAdminService.delete(id);
        return Result.success();
    }

    /**
     * 详情
     *
     * @param id
     * @return
     */
    @At("/get/{id}")
    @Ok("json")
    @GET
    @ApiOperation(name = "详情信息")
    @ApiFormParams(
            {
                    @ApiFormParam(name = "id", description = "唯一标识")
            }
    )
    @SLog(tag = "详情信息", value = "${args[0]}")
    @SaCheckLogin
    public Result<?> detail(@Param("id") String id) {
        return Result.data(sqfwNoticeForAdminService.detail(id));
    }

    /**
     * excel下载
     * @param sqfwFormSummaryForAdminVO
     * @return
     */
    @At
    @Ok("json")
    @POST
    @ApiOperation(name = "Excel文件下载")
    @SLog(tag = "Excel文件下载", value = "${args[0]}")
    @SaCheckLogin
    public Result<?> downloadExcel(@Param("excelConfigList") List<ExcelCreateConfig> excelConfigList, @Param("..") SqfwNoticeForAdminVO sqfwFormSummaryForAdminVO) {
        return Result.data(sqfwNoticeForAdminService.downloadExcel(excelConfigList, sqfwFormSummaryForAdminVO));
    }

    /**
     * pdf下载
     * @param sqfwFormSummaryForAdminVO
     * @return
     */
    @At
    @Ok("json")
    @POST
    @ApiOperation(name = "pdf文件下载")
    @SLog(tag = "pdf文件下载", value = "${args[0]}")
    @SaCheckLogin
    public Result<?> downloadPdf(@Param("excelConfigList") List<ExcelCreateConfig> excelConfigList, @Param("..") SqfwNoticeForAdminVO sqfwFormSummaryForAdminVO) {
        return Result.data(sqfwNoticeForAdminService.downloadPdf(excelConfigList, sqfwFormSummaryForAdminVO));
    }
}
